package com.hub.grpc.server.service;


import com.hub.grpc.proto.HelloRequest;
import com.hub.grpc.proto.HelloResponse;
import com.hub.grpc.proto.HelloServiceGrpc;
import com.hub.grpc.server.annotation.GrpcService;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;

/**
 * @ author 飞天蝙蝠
 * @ date & time 2024/12/30 15:53
 */
@Slf4j
@GrpcService
public class HelloService extends HelloServiceGrpc.HelloServiceImplBase {

    @Override
    public void hello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
        log.info(" HelloService 接收到的参数，name：{}", request.getName());

        String greeting = "Hi " + request.getName() + " ,you are " + request.getAge() + " years old" +
                " ,your hoby is " + (request.getHobbiesList()) + " ,your tags " + request.getTagsMap();

        HelloResponse response = HelloResponse.newBuilder().setGreeting(greeting).build();
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }
}
